clear all

use COMBINED_waves_1234.dta, clear


***Recode states in order***
rename inputstate state
sort state
recode state (4=3) (5=4) (6=5) (8=6) (9=7) (10=8) (11=9) (12=10) (13=11) (15=12) (16=13) (17=14) (18=15) (19=16) (20=17) (21=18) (22=19) (23=20) (24=21) (25=22) (26=23) (27=24) (28=25) (29=26) (30=27) (31=28) (32=29) (33=30) (34=31) (35=32) (36=33) (37=34) (38=35) (39=36) (40=37) (41=38) (42=39) (44=40) (45=41) (46=42) (47=43) (48=44) (49=45) (50=46) (51=47) (53=48) (54=49) (55=50) (56=51)

***Label states**
label define statelabels 1 "Alabama" 2 "Alaska" 3 "Arizona" 4 "Arkansas" 5 "California" 6 "Colorado" 7 "Connecticut" 8 "Delaware" 9 "District of Columbia" 10 "Florida" 11 "Georgia" 12 "Hawaii" 13 "Idaho" 14 "Illinois" 15 "Indiana" 16 "Iowa" 17 "Kansas" 18 "Kentucky" 19 "Louisiana" 20 "Maine" 21 "Maryland" 22 "Massachusetts" 23 "Michigan" 24 "Minnesota" 25 "Mississippi" 26 "Missouri" 27 "Montana" 28 "Nebraska" 29 "Nevada" 30 "New Hampshire" 31 "New Jersey" 32 "New Mexico" 33 "New York" 34 "North Carolina" 35 "North Dakota" 36 "Ohio" 37 "Oklahoma" 38 "Oregon" 39 "Pennsylvania" 40 "Rhode Island" 41 "South Carolina" 42 "South Dakota" 43 "Tennessee" 44 "Texas" 45 "Utah" 46 "Vermont" 47 "Virginia" 48 "Washington" 49 "West Virginia" 50 "Wisconsin" 51 "Wyoming"
label values state statelabels

***Create string utility variable***
gen utility_type=.
replace utility_type=1 if OwnershipType=="Municipal"
replace utility_type=2 if OwnershipType=="Investor Owned"
replace utility_type=3 if OwnershipType=="Cooperative"
label define utilitylabel 1 "Municipal" 2 "IOU" 3 "Coop"
label values utility_type utilitylabel

gen muni = (utility_type==1)
gen iou = (utility_type==2)
gen coop = (utility_type==3)

save COMBINED_waves_1234.dta, replace


****Collapse dataset into variable of interest for each month, rename variables into common names, and append****
******May Data******
use COMBINED_waves_1234.dta, replace
keep weight1 weight4 caseid_National caseid_Indiana caseid_w1 state inputzip1 marstat utility_type muni iou coop electricity1 gas1 wood1 propane1 fueloil1 age hhsize1 hh_under51 any_under51 any_over651 hh_over651 covid_lostwork1 covid_insurance1 covid_lessinsurance1 no_insurance1 any_disability1 home_trailer1 home_apartmentcondo1 home_singlefam1 home_other1 hh_disability1 educ1 educ_HS1 homeowner1 ownhome1 retired race white black hispanic native_american female hhinc1 fpl1 under_100_fpl1 FPL_100_1501 FPL_150_2001 dwelling_type1 poor_insulation1 drafty1 mold1 holes1 plumbing1 exposed_sockets1 nonworking_stove_fridge1 broken_ac1 dwelling_condition1 fuel_payment1 hhbill_year notice_year disconnect_year hhbill_3months1 notice_3months1 disconnect_3months1 hhbill_may notice_may disconnect_may electronic_device1 energybill_change1 covid_stimulus1 energy_assistance_may gov_agency_may energy_provider_may friend_family_may faith_org_may nonprofit_may payday_lender_may bankloan_may gov_assistance_may covid_foregoexpenses wap_may liheap_may snap_may tanf_may ssi_may medicaid_may vet_benefits_may unemp_insurance_may gov_assistance_may stove_may spaceheater_may woodstove_may fireplace_may hotshower_may burntrash_may heavycoat_may boughtice_may coldshower_may covid_employment1 covid_rent1 covid_feedfamily1 covid_medicalcare1 covid_lostinsurance1 date_unemployed1 employed1 unemployed1 employ1 hh1_income1 hh2_income1 hh3_income1 hh4_income1 hh5_income1 hh6_income1 hh7_income1 hh8_income1 income1 covid_employmentchange_open1 employmentstatus_open1 maintaintemp_open1 energyassist_lastyr_open1 govassistance_lastyr_open1 monthly_rent1 monthly_energy1 monthly_groceries pcturban gov_assistance_year



drop if hhbill_may==.

gen wave=1

rename weight1 weight
rename weight4 weight_balanced
rename inputzip1 zip
rename electricity1 electricity
rename gas1 gas
rename wood1 wood
rename propane1 propane
rename fueloil1 fueloil
rename hhsize1 hhsize
rename hh_under51 hh_under5
rename hh_over651 hh_over65
rename any_under51 any_under5
rename any_over651 any_over65
rename covid_lostwork1 covid_lostwork
rename covid_insurance1 covid_insurance
rename covid_lessinsurance1 covid_lessinsurance
rename no_insurance1 no_insurance
rename any_disability1 any_disability
rename home_trailer1 home_trailer
rename home_apartmentcondo1 home_apartmentcondo
rename home_singlefam1 home_singlefam
rename home_other1 home_other
rename hh_disability1 hh_disability
rename educ1 educ
rename educ_HS1 educ_HS
rename homeowner1 homeowner
rename ownhome1 ownhome
rename hhinc1 hhinc
rename fpl1 fpl
rename under_100_fpl1 under_100_fpl
rename FPL_100_1501 FPL_100_150
rename FPL_150_2001 FPL_150_200
rename poor_insulation1 poor_insulation
rename dwelling_type1 dwelling_type
rename drafty1 drafty
rename mold1 mold
rename holes1 holes
rename plumbing1 plumbing
rename exposed_sockets1 exposed_sockets
rename nonworking_stove_fridge1 nonworking_stove_fridge
rename broken_ac1 broken_ac
rename dwelling_condition1 dwelling_condition
rename fuel_payment1 fuel_payment
rename hhbill_may hhbill
rename notice_may notice
rename disconnect_may disconnect
rename electronic_device1 electronic_device
rename energybill_change1 energybill_change
rename covid_stimulus1 stimulus
rename energy_assistance_may energy_assistance
rename gov_agency_may gov_agency
rename energy_provider_may energy_provider
rename friend_family_may friend_family
rename faith_org_may faith_org
rename nonprofit_may nonprofit
rename payday_lender_may payday_lender
rename bankloan_may bankloan
rename gov_assistance_may gov_assistance
rename covid_foregoexpenses forego_expenses
rename wap_may wap
rename liheap_may liheap
rename snap_may snap
rename tanf_may tanf
rename ssi_may ssi
rename medicaid_may medicaid
rename vet_benefits_may vet_benefits
rename unemp_insurance_may unemp_insurance
rename stove_may stove
rename spaceheater_may spaceheater
rename woodstove_may woodstove
rename fireplace_may fireplace
rename hotshower_may hotshower
rename burntrash_may burntrash
rename heavycoat_may heavycoat
rename boughtice_may boughtice
rename coldshower_may coldshower
rename covid_employment1 covid_employment
rename covid_rent1 covid_rent
rename covid_feedfamily1 covid_feedfamily
rename covid_medicalcare1 covid_medicalcare
rename covid_lostinsurance1 covid_lostinsurance
rename date_unemployed1 date_unemployed
rename employed1 employed
rename unemployed1 unemployed
rename employ1 employ
rename hh1_income1 hh1_income
rename hh2_income1 hh2_income
rename hh3_income1 hh3_income
rename hh4_income1 hh4_income
rename hh5_income1 hh5_income
rename hh6_income1 hh6_income
rename hh7_income1 hh7_income
rename hh8_income1 hh8_income
rename income1 income



save wave1_energy_insecurity.dta, replace



******Wave 2 Data******
use COMBINED_waves_1234.dta, replace
keep weight2 weight4 caseid_National caseid_Indiana caseid_w1 inputzip2 marstat state utility_type muni iou coop electricity2 gas2 wood2 propane2 fueloil2 age hhsize2 hh_under52 any_under52 any_over652 hh_over652 covid_lostwork2 covid_insurance2 covid_lessinsurance2 no_insurance2 any_disability2 home_trailer2 home_apartmentcondo2 home_singlefam2 home_other2 utilitybill_pay_irregular2 utilitydebt_over1002 genhealth_goodtogreat2 hh_disability2 educ2 educ_HS2 homeowner2 ownhome2 retired race white black hispanic native_american female fpl2 hhinc2 under_100_fpl2 FPL_100_1502 FPL_150_2002 FPL_over_2002 dwelling_type1 dwelling_type2 poor_insulation2 drafty2 mold2 holes2 plumbing2 exposed_sockets2 nonworking_stove_fridge2 broken_ac2 trust_energyco2 dwelling_condition1 dwelling_condition2 fuel_payment2 hhbill_3months2 notice_3months2 disconnect_3months2 electronic_device2 energybill_change2 covid_stimulus2 energy_assistance_3mos2 gov_agency_3mos2 energy_provider_3mos2 friend_family_3mos2 faith_org_3mos2 nonprofit_3mos2 payday_lender_3mos2 bankloan_3mos2 gov_assistance_3months2 forego_expenses_3mos2 wap_3mos2 liheap_3mos2 snap_3mos2 tanf_3mos2 ssi_3mos2 medicaid_3mos2 vet_benefits_3mos2 unemp_insurance_3mos2 stove_3mos2 spaceheater_3mos2 woodstove_3mos2 fireplace_3mos2 hotshower_3mos2 burntrash_3mos2 heavycoat_3mos2 boughtice_3mos2 coldshowers_3mos2 dryer_3mos2 centralac_3mos2 windowac_3mos2 fan_3mos2 dehumidifier_3mos2 lefthouse_3mos2 openedwindows_3mos2 covid_employment2 covid_rent2 covid_feedfamily2 covid_medicalcare2 covid_lostinsurance2 date_unemployed2 employed2 unemployed2 employ2 efficient_appliances2 efficient_insulation2 efficient_ac2 efficient_smartmeter2 efficient_lights2 efficient_hometemp2 efficient_devices2 efficient_hungwindow2 utilitypay_check2 utilitypay_credit2 utilitypay_debit2 utilitypay_withdrawal2 utilitypay_cash2 utilitybill_pay2 utilityhelp_friend2 utilityhelp_paydayloan2 utilityhelp_credit2 utilityhelp_notice2 utility_debt2 debt_over10002 behind_rent2 behind_credit2 behind_car2 behind_medical2 behind_bankloan2 behind_personalloan2 behind_studentloan2 evictnotice_3months2 evicted_3months2 legal_help2 legal_access2 legal_source2 generalhealth_rate2 prescription2 fill_prescription2 mentalhealth_days2 highbloodpressure2 heartdisease2 diabetes2 cancer2 obesity2 asthma2 hh1_income2 hh2_income2 hh3_income2 hh4_income2 hh5_income2 hh6_income2 hh7_income2 hh8_income2 income2 dwelling_open2 employmentstatus_open2 chronic_conditions_open2 debt_over1000_open2 maintainbills_open2 utilitybillpay_open2 utilitybillhelp_open2 utilitypaymethod_open2 covid_employmentchange_open2 staycool_open2 staywarm_open2 govassist_open2 energyassist_open2 response_notice_open2 energyefficiency_open2 sought_govagency2 sought_bank2 sought_payday2 sought_utility2 sought_nonprofit2 sought_faithbased2 sought_family_friends2 form_call2 form_letter2 form_doorknock2 form_email2 form_text2 received_govagency2 received_bank2 received_payday2 received_utility2 received_nonprofit2 received_faithbased2 received_family_friends2 response_contactutility2 response_paymentplan2 response_legalservices2 response_assistance2 response_internet2 response_homechanges2 response_reduceenergy2 response_moved2 reconnection_cost2 response_moved_temp2 response_moved_perm2 response_livedwithout2 response_otherhelp2 response_paidoff2 response_usedothers2 response_carorbattery2 no_ac2 no_ac_reason2 pcturban gov_assistance_year

drop if hhbill_3months2==.

gen wave=2

rename weight2 weight
rename weight4 weight_balanced
rename inputzip2 zip
rename electricity2 electricity
rename gas2 gas
rename wood2 wood
rename propane2 propane
rename fueloil2 fueloil
rename hhsize2 hhsize
rename hh_under52 hh_under5
rename hh_over652 hh_over65
rename any_under52 any_under5
rename any_over652 any_over65
rename covid_lostwork2 covid_lostwork
rename covid_insurance2 covid_insurance
rename covid_lessinsurance2 covid_lessinsurance
rename no_insurance2 no_insurance
rename any_disability2 any_disability
rename home_trailer2 home_trailer
rename home_apartmentcondo2 home_apartmentcondo
rename home_singlefam2 home_singlefam
rename home_other2 home_other
rename utilitybill_pay_irregular2 utilitybill_pay_irregular
rename utilitydebt_over1002 utility_debt_over100
rename genhealth_goodtogreat2 genhealth_goodtogreat
rename hh_disability2 hh_disability
rename educ2 educ
rename educ_HS2 educ_HS
rename homeowner2 homeowner
rename ownhome2 ownhome
rename hhinc2 hhinc
rename fpl2 fpl
rename under_100_fpl2 under_100_fpl
rename FPL_100_1502 FPL_100_150
rename FPL_150_2002 FPL_150_200
rename FPL_over_2002 FPL_over_200
rename poor_insulation2 poor_insulation
rename dwelling_type1 dwelling_type
rename drafty2 drafty
rename mold2 mold
rename holes2 holes
rename plumbing2 plumbing
rename exposed_sockets2 exposed_sockets
rename nonworking_stove_fridge2 nonworking_stove_fridge
rename broken_ac2 broken_ac
gen dwelling_condition=0
replace dwelling_condition=1 if dwelling_condition1==1 | dwelling_condition2==1
rename trust_energyco2 trust_energyco
rename fuel_payment2 fuel_payment
rename hhbill_3months2 hhbill
rename notice_3months2 notice
rename disconnect_3months2 disconnect
rename electronic_device2 electronic_device
rename energybill_change2 energybill_change
rename covid_stimulus2 stimulus
rename energy_assistance_3mos2 energy_assistance
rename gov_agency_3mos2 gov_agency
rename energy_provider_3mos2 energy_provider
rename friend_family_3mos2 friend_family
rename faith_org_3mos2 faith_org
rename nonprofit_3mos2 nonprofit
rename payday_lender_3mos2 payday_lender
rename bankloan_3mos2 bankloan
rename gov_assistance_3months2 gov_assistance
rename forego_expenses_3mos2 forego_expenses
rename wap_3mos2 wap
rename liheap_3mos2 liheap
rename snap_3mos2 snap
rename tanf_3mos2 tanf
rename ssi_3mos2 ssi
rename medicaid_3mos2 medicaid
rename vet_benefits_3mos2 vet_benefits
rename unemp_insurance_3mos2 unemp_insurance
rename stove_3mos2 stove
rename spaceheater_3mos2 spaceheater
rename woodstove_3mos2 woodstove
rename fireplace_3mos2 fireplace
rename hotshower_3mos2 hotshower
rename burntrash_3mos2 burntrash
rename heavycoat_3mos2 heavycoat
rename boughtice_3mos2 boughtice
rename coldshowers_3mos2 coldshower
rename dryer_3mos2 dryer
rename centralac_3mos2 centralac
rename windowac_3mos2 windowac
rename fan_3mos2 fan
rename dehumidifier_3mos2 dehumidifier
rename lefthouse_3mos2 lefthouse
rename openedwindows_3mos2 openedwindows
rename covid_employment2 covid_employment
rename covid_rent2 covid_rent
rename covid_feedfamily2 covid_feedfamily
rename covid_medicalcare2 covid_medicalcare
rename covid_lostinsurance2 covid_lostinsurance
rename date_unemployed2 date_unemployed
rename employed2 employed
rename unemployed2 unemployed
rename employ2 employ
rename efficient_appliances2 efficient_appliances
rename efficient_insulation2 efficient_insulation
rename efficient_ac2 efficient_ac
rename efficient_smartmeter2 efficient_smartmeter
rename efficient_lights2 efficient_lights
rename efficient_hometemp2 efficient_hometemp
rename efficient_devices2 efficient_devices
rename efficient_hungwindow2 efficient_hungwindow
rename utilitypay_check2 utilitypay_check
rename utilitypay_credit2 utilitypay_credit
rename utilitypay_debit2 utilitypay_debite
rename utilitypay_withdrawal2 utilitypay_withdrawal
rename utilitypay_cash2 utilitypay_cash
rename utilitybill_pay2 utilitybill_pay
rename utilityhelp_friend2 utilityhelp_friend
rename utilityhelp_paydayloan2 utilityhelp_paydayloan
rename utilityhelp_credit2 utilityhelp_credit
rename utilityhelp_notice2 utilityhelp_notice
rename utility_debt2 utility_debt
rename debt_over10002 debt_over1000
rename behind_rent2 behind_rent
rename behind_credit2 behind_credit
rename behind_car2 behind_car
rename behind_medical2 behind_medical
rename behind_bankloan2 behind_bankloan
rename behind_personalloan2 behind_personalloan
rename behind_studentloan2 behind_studentloan
rename evictnotice_3months2 evict_notice
rename evicted_3months2 evicted
rename legal_help2 legal_help
rename legal_access2 legal_access
rename legal_source2 legal_source
rename generalhealth_rate2 generalhealth_rate
rename prescription2 prescription
rename fill_prescription2 fill_prescription
rename mentalhealth_days2 mentalhealth_days
rename highbloodpressure2 highbloodpressure
rename heartdisease2 heartdisease
rename diabetes2 diabetes
rename cancer2 cancer
rename obesity2 obesity
rename asthma2 asthma
rename hh1_income2 hh1_income
rename hh2_income2 hh2_income
rename hh3_income2 hh3_income
rename hh4_income2 hh4_income
rename hh5_income2 hh5_income
rename hh6_income2 hh6_income
rename hh7_income2 hh7_income
rename hh8_income2 hh8_income
rename income2 income
rename sought_govagency2 sought_govagency
rename sought_bank2 sought_bank
rename sought_payday2 sought_payday
rename sought_utility2 sought_utility
rename sought_nonprofit2 sought_nonprofit
rename sought_faithbased2 sought_faithbased
rename sought_family_friends2 sought_family_friends
rename form_call2 form_call
rename form_letter2 form_letter 
rename form_doorknock2 form_doorknock 
rename form_email2 form_email 
rename form_text2 form_text
rename received_govagency2 received_govagency
rename received_bank2 received_bank
rename received_payday2 received_payday
rename received_utility2 received_utility
rename received_nonprofit2 received_nonprofit
rename received_faithbased2 received_faithbased
rename received_family_friends2 received_family_friends
rename response_contactutility2 response_contactutility
rename response_paymentplan2 response_paymentplan
rename response_legalservices2 response_legalservices
rename response_assistance2 response_assistance
rename response_internet2 response_internet
rename response_homechanges2 response_homechanges
rename response_reduceenergy2 response_reduceenergy
rename response_moved2 response_moved
rename reconnection_cost2 reconnection_cost
rename response_moved_temp2 response_moved_temp
rename response_moved_perm2 response_moved_perm
rename response_livedwithout2 response_livedwithout
rename response_otherhelp2 response_otherhelp
rename response_paidoff2 response_paidoff
rename response_usedothers2 response_usedothers
rename response_carorbattery2 response_carorbattery
rename no_ac2 no_ac
rename no_ac_reason2 no_ac_reason



save wave2_energy_insecurity.dta, replace








******Wave 3 Data******
use COMBINED_waves_1234.dta, replace
keep weight3 weight4 caseid_National caseid_Indiana caseid_w1 inputzip3 marstat state utility_type muni iou coop electricity3 gas3 wood3 propane3 fueloil3 age hhsize3 hh_under53 any_under53 any_over653 hh_over653 covid_lostwork3 covid_insurance3 covid_lessinsurance3 no_insurance3 any_disability3 home_trailer3 home_apartmentcondo3 home_singlefam3 home_other3 utilitybill_pay_irregular3 utilitydebt_over1003 genhealth_goodtogreat3 hh_disability3 educ3 educ_HS3 homeowner3 ownhome3 retired race white black hispanic native_american female fpl3 hhinc3 under_100_fpl3 FPL_100_1503 FPL_150_2003 FPL_over_2003 dwelling_type1 dwelling_type3 poor_insulation3 drafty3 mold3 holes3 plumbing3 exposed_sockets3 nonworking_stove_fridge3 broken_ac3 trust_energyco3 dwelling_condition1 dwelling_condition2 dwelling_condition3 fuel_payment3 hhbill_5months notice_5months disconnect_5months electronic_device3 energybill_change3 stimulus_5mos energy_assistance_5mos gov_agency_5mos energy_provider_5mos friend_family_5mos faith_org_5mos nonprofit_5mos payday_lender_5mos bankloan_5mos gov_assistance_5months forego_expenses_5mos wap_5mos liheap_5mos snap_5mos tanf_5mos ssi_5mos medicaid_5mos vet_benefits_5mos unemp_insurance_5mos stove_5mos spaceheater_5mos woodstove_5mos fireplace_5mos hotshower_5mos burntrash_5mos heavycoat_5mos boughtice_5mos coldshowers_5mos dryer_5mos centralac_5mos windowac_5mos fan_5mos dehumidifier_5mos lefthouse_5mos openedwindows_5mos covid_employment3 covid_rent3 covid_feedfamily3 covid_medicalcare3 covid_lostinsurance3 date_unemployed3 employed3 unemployed3 employ3 efficient_appliances3 efficient_insulation3 efficient_ac3 efficient_smartmeter3 efficient_lights3 efficient_hometemp3 efficient_devices3 efficient_hungwindow3 utilitypay_check3 utilitypay_credit3 utilitypay_debit3 utilitypay_withdrawal3 utilitypay_cash3 utilitybill_pay3 utilityhelp_friend3 utilityhelp_paydayloan3 utilityhelp_credit3 utilityhelp_notice3 utility_debt3 debt_over10003 behind_rent3 behind_credit3 behind_car3 behind_medical3 behind_bankloan3 behind_personalloan3 behind_studentloan3 evictnotice_5months evicted_5months legal_help3 legal_access3 legal_source3 generalhealth_rate3 prescription3 fill_prescription3 mentalhealth_days3 highbloodpressure3 heartdisease3 diabetes3 cancer3 obesity3 asthma3 skipped_meals3 skipped_meals_frequency3 water_bill3 water_shutoff3 hh1_income3 hh2_income3 hh3_income3 hh4_income3 hh5_income3 hh6_income3 hh7_income3 hh8_income3 income3 dwelling_open3 maintainbills_open3 debt_over1000_open3 chronic_conditions_open3 covid_employmentchange_open3 utilitybillpay_open3 utilitybillhelp_open3 utilitypaymethod_open3 staycool_open3 staywarm_open3 govassist_open3 energyassist_open3 response_notice_open3 energyefficiency_open3 sought_govagency3 sought_bank3 sought_payday3 sought_utility3 sought_nonprofit3 sought_faithbased3 sought_family_friends3 form_call3 form_letter3 form_doorknock3 form_email3 form_text3  response_contactutility3 response_paymentplan3 response_legalservices3 response_assistance3 response_internet3 response_homechanges3 response_reduceenergy3 response_moved3 reconnection_cost3 response_moved_temp3 response_moved_perm3 response_livedwithout3 response_otherhelp3 response_paidoff3 response_usedothers3 response_carorbattery3 no_ac3 no_ac_reason3 pcturban gov_assistance_year

drop if hhbill_5months==.

gen wave=3

rename weight3 weight
rename weight4 weight_balanced
rename inputzip3 zip
rename electricity3 electricity
rename gas3 gas
rename wood3 wood
rename propane3 propane
rename fueloil3 fueloil
rename hhsize3 hhsize
rename hh_under53 hh_under5
rename hh_over653 hh_over65
rename any_under53 any_under5
rename any_over653 any_over65
rename covid_lostwork3 covid_lostwork
rename covid_insurance3 covid_insurance
rename covid_lessinsurance3 covid_lessinsurance
rename no_insurance3 no_insurance
rename any_disability3 any_disability
rename home_trailer3 home_trailer
rename home_apartmentcondo3 home_apartmentcondo
rename home_singlefam3 home_singlefam
rename home_other3 home_other
rename utilitybill_pay_irregular3 utilitybill_pay_irregular
rename utilitydebt_over1003 utility_debt_over100
rename genhealth_goodtogreat3 genhealth_goodtogreat
rename hh_disability3 hh_disability
rename educ3 educ
rename educ_HS3 educ_HS
rename homeowner3 homeowner
rename ownhome3 ownhome
rename hhinc3 hhinc
rename fpl3 fpl
rename under_100_fpl3 under_100_fpl
rename FPL_100_1503 FPL_100_150
rename FPL_150_2003 FPL_150_200
rename FPL_over_2003 FPL_over_200
rename poor_insulation3 poor_insulation
rename dwelling_type1 dwelling_type
rename drafty3 drafty
rename mold3 mold
rename holes3 holes
rename plumbing3 plumbing
rename exposed_sockets3 exposed_sockets
rename nonworking_stove_fridge3 nonworking_stove_fridge
rename broken_ac3 broken_ac
gen dwelling_condition=0
replace dwelling_condition=1 if dwelling_condition1==1 | dwelling_condition2==1 | dwelling_condition3
rename trust_energyco3 trust_energyco
rename fuel_payment3 fuel_payment
rename hhbill_5months hhbill
rename notice_5months notice
rename disconnect_5months disconnect
rename electronic_device3 electronic_device
rename energybill_change3 energybill_change
rename stimulus_5mos stimulus
rename energy_assistance_5mos energy_assistance
rename gov_agency_5mos gov_agency
rename energy_provider_5mos energy_provider
rename friend_family_5mos friend_family
rename faith_org_5mos faith_org
rename nonprofit_5mos nonprofit
rename payday_lender_5mos payday_lender
rename bankloan_5mos bankloan
rename gov_assistance_5months gov_assistance
rename forego_expenses_5mos forego_expenses
rename wap_5mos wap
rename liheap_5mos liheap
rename snap_5mos snap
rename tanf_5mos tanf
rename ssi_5mos ssi
rename medicaid_5mos medicaid
rename vet_benefits_5mos vet_benefits
rename unemp_insurance_5mos unemp_insurance
rename stove_5mos stove
rename spaceheater_5mos spaceheater
rename woodstove_5mos woodstove
rename fireplace_5mos fireplace
rename hotshower_5mos hotshower
rename burntrash_5mos burntrash
rename heavycoat_5mos heavycoat
rename boughtice_5mos boughtice
rename coldshowers_5mos coldshower
rename dryer_5mos dryer
rename centralac_5mos centralac
rename windowac_5mos windowac
rename fan_5mos fan
rename dehumidifier_5mos dehumidifier
rename lefthouse_5mos lefthouse
rename openedwindows_5mos openedwindows
rename covid_employment3 covid_employment
rename covid_rent3 covid_rent
rename covid_feedfamily3 covid_feedfamily
rename covid_medicalcare3 covid_medicalcare
rename covid_lostinsurance3 covid_lostinsurance
rename date_unemployed3 date_unemployed
rename employed3 employed
rename unemployed3 unemployed
rename employ3 employ
rename efficient_appliances3 efficient_appliances
rename efficient_insulation3 efficient_insulation
rename efficient_ac3 efficient_ac
rename efficient_smartmeter3 efficient_smartmeter
rename efficient_lights3 efficient_lights
rename efficient_hometemp3 efficient_hometemp
rename efficient_devices3 efficient_devices
rename efficient_hungwindow3 efficient_hungwindow
rename utilitypay_check3 utilitypay_check
rename utilitypay_credit3 utilitypay_credit
rename utilitypay_debit3 utilitypay_debite
rename utilitypay_withdrawal3 utilitypay_withdrawal
rename utilitypay_cash3 utilitypay_cash
rename utilitybill_pay3 utilitybill_pay
rename utilityhelp_friend3 utilityhelp_friend
rename utilityhelp_paydayloan3 utilityhelp_paydayloan
rename utilityhelp_credit3 utilityhelp_credit
rename utilityhelp_notice3 utilityhelp_notice
rename utility_debt3 utility_debt
rename debt_over10003 debt_over1000
rename behind_rent3 behind_rent
rename behind_credit3 behind_credit
rename behind_car3 behind_car
rename behind_medical3 behind_medical
rename behind_bankloan3 behind_bankloan
rename behind_personalloan3 behind_personalloan
rename behind_studentloan3 behind_studentloan
rename evictnotice_5months evict_notice
rename evicted_5months evicted
rename legal_help3 legal_help
rename legal_access3 legal_access
rename legal_source3 legal_source
rename generalhealth_rate3 generalhealth_rate
rename prescription3 prescription
rename fill_prescription3 fill_prescription
rename mentalhealth_days3 mentalhealth_days
rename highbloodpressure3 highbloodpressure
rename heartdisease3 heartdisease
rename diabetes3 diabetes
rename cancer3 cancer
rename obesity3 obesity
rename asthma3 asthma
rename skipped_meals3 skipped_meals
rename skipped_meals_frequency3 skipped_meals_frequency
rename water_bill3 water_bill
rename water_shutoff3 water_shutoff
rename hh1_income3 hh1_income
rename hh2_income3 hh2_income
rename hh3_income3 hh3_income
rename hh4_income3 hh4_income
rename hh5_income3 hh5_income
rename hh6_income3 hh6_income
rename hh7_income3 hh7_income
rename hh8_income3 hh8_income
rename income3 income
rename sought_govagency3 sought_govagency
rename sought_bank3 sought_bank
rename sought_payday3 sought_payday
rename sought_utility3 sought_utility
rename sought_nonprofit3 sought_nonprofit
rename sought_faithbased3 sought_faithbased
rename sought_family_friends3 sought_family_friends
rename form_call3 form_call
rename form_letter3 form_letter 
rename form_doorknock3 form_doorknock 
rename form_email3 form_email 
rename form_text3 form_text
rename response_contactutility3 response_contactutility
rename response_paymentplan3 response_paymentplan
rename response_legalservices3 response_legalservices
rename response_assistance3 response_assistance
rename response_internet3 response_internet
rename response_homechanges3 response_homechanges
rename response_reduceenergy3 response_reduceenergy
rename response_moved3 response_moved
rename reconnection_cost3 reconnection_cost
rename response_moved_temp3 response_moved_temp
rename response_moved_perm3 response_moved_perm
rename response_livedwithout3 response_livedwithout
rename response_otherhelp3 response_otherhelp
rename response_paidoff3 response_paidoff
rename response_usedothers3 response_usedothers
rename response_carorbattery3 response_carorbattery
rename no_ac3 no_ac
rename no_ac_reason3 no_ac_reason



save wave3_energy_insecurity.dta, replace




******Wave 4 Data******
use COMBINED_waves_1234.dta, replace
keep weight4 caseid_National caseid_Indiana caseid_w1 inputzip4 marstat state utility_type muni iou coop electricity4 gas4 wood4 propane4 fueloil4 age hhsize4 hh_under54 any_under54 any_over654 hh_over654 covid_lostwork4 covid_insurance4 covid_lessinsurance4 no_insurance4 any_disability4 home_trailer4 home_apartmentcondo4 home_singlefam4 home_other4 utilitybill_pay_irregular4 utilitydebt_over1004 genhealth_goodtogreat4 hh_disability4 educ4 educ_HS4 homeowner4 ownhome4 retired race white black hispanic native_american female fpl4 hhinc4 under_100_fpl4 FPL_100_1504 FPL_150_2004 FPL_over_2004 dwelling_type1 dwelling_type4 poor_insulation4 drafty4 mold4 holes4 plumbing4 exposed_sockets4 nonworking_stove_fridge4 broken_ac4 trust_energyco4 dwelling_condition1 dwelling_condition2 dwelling_condition3 dwelling_condition4 dwelling_condition4 fuel_payment4 hhbill_4months notice_4months disconnect_4months electronic_device4 energybill_change4 stimulus_4mos energy_assistance_4mos gov_agency_4mos energy_provider_4mos friend_family_4mos faith_org_4mos nonprofit_4mos payday_lender_4mos bankloan_4mos gov_assistance_4months forego_expenses_4mos wap_4mos liheap_4mos snap_4mos tanf_4mos ssi_4mos medicaid_4mos vet_benefits_4mos unemp_insurance_4mos stove_4mos spaceheater_4mos woodstove_4mos fireplace_4mos hotshower_4mos burntrash_4mos heavycoat_4mos boughtice_4mos coldshowers_4mos dryer_4mos centralac_4mos windowac_4mos fan_4mos dehumidifier_4mos lefthouse_4mos openedwindows_4mos covid_employment4 covid_rent4 covid_feedfamily4 covid_medicalcare4 covid_lostinsurance4 date_unemployed4 employed4 unemployed4 employ4 efficient_appliances4 efficient_insulation4 efficient_ac4 efficient_smartmeter4 efficient_lights4 efficient_hometemp4 efficient_devices4 efficient_hungwindow4 utilitypay_check4 utilitypay_credit4 utilitypay_debit4 utilitypay_withdrawal4 utilitypay_cash4 utilitybill_pay4 utilityhelp_friend4 utilityhelp_paydayloan4 utilityhelp_credit4 utilityhelp_notice4 utility_debt4 debt_over10004 behind_rent4 behind_credit4 behind_car4 behind_medical4 behind_bankloan4 behind_personalloan4 behind_studentloan4 evictnotice_4months evicted_4months legal_help4 legal_access4 legal_source4 generalhealth_rate4 prescription4 fill_prescription4 mentalhealth_days4 highbloodpressure4 heartdisease4 diabetes4 cancer4 obesity4 asthma4 skipped_meals4 skipped_meals_frequency4 water_bill4 water_shutoff4 hh1_income4 hh2_income4 hh3_income4 hh4_income4 hh5_income4 hh6_income4 hh7_income4 hh8_income4 income4 dwelling_open4 employmentstatus_open4 maintainbills_open4 debt_over1000_open4 chronic_conditions_open4 covid_employmentchange_open4 utilitybillpay_open4 utilitybillhelp_open4 utilitypaymethod_open4 staycool_open4 staywarm_open4 govassist_open4 energyassist_open4 response_notice_open4 energyefficiency_open4 sought_govagency4 sought_bank4 sought_payday4 sought_utility4 sought_nonprofit4 sought_faithbased4 sought_family_friends4 form_call4 form_letter4 form_doorknock4 form_email4 form_text4 response_contactutility4 response_paymentplan4 response_legalservices4 response_assistance4 response_internet4 response_homechanges4 response_reduceenergy4 response_moved4 reconnection_cost4 response_moved_temp4 response_moved_perm4 response_livedwithout4 response_otherhelp4 response_paidoff4 response_usedothers4 response_carorbattery4 no_ac4 no_ac_reason4 pcturban gov_assistance_year



drop if hhbill_4months==.

gen wave=4

rename weight4 weight
clonevar weight_balanced = weight
rename inputzip4 zip
rename electricity4 electricity
rename gas4 gas
rename wood4 wood
rename propane4 propane
rename fueloil4 fueloil
rename hhsize4 hhsize
rename hh_under54 hh_under5
rename hh_over654 hh_over65
rename any_under54 any_under5
rename any_over654 any_over65
rename covid_lostwork4 covid_lostwork
rename covid_insurance4 covid_insurance
rename covid_lessinsurance4 covid_lessinsurance
rename no_insurance4 no_insurance
rename any_disability4 any_disability
rename home_trailer4 home_trailer
rename home_apartmentcondo4 home_apartmentcondo
rename home_singlefam4 home_singlefam
rename home_other4 home_other
rename utilitybill_pay_irregular4 utilitybill_pay_irregular
rename utilitydebt_over1004 utility_debt_over100
rename genhealth_goodtogreat4 genhealth_goodtogreat
rename hh_disability4 hh_disability
rename educ4 educ
rename educ_HS4 educ_HS
rename homeowner4 homeowner
rename ownhome4 ownhome
rename hhinc4 hhinc
rename fpl4 fpl
rename under_100_fpl4 under_100_fpl
rename FPL_100_1504 FPL_100_150
rename FPL_150_2004 FPL_150_200
rename FPL_over_2004 FPL_over_200
rename poor_insulation4 poor_insulation
rename dwelling_type1 dwelling_type
rename drafty4 drafty
rename mold4 mold
rename holes4 holes
rename plumbing4 plumbing
rename exposed_sockets4 exposed_sockets
rename nonworking_stove_fridge4 nonworking_stove_fridge
rename broken_ac4 broken_ac
gen dwelling_condition=0
replace dwelling_condition=1 if dwelling_condition1==1 | dwelling_condition2==1 | dwelling_condition3 | dwelling_condition4
rename trust_energyco4 trust_energyco
rename fuel_payment4 fuel_payment
rename hhbill_4months hhbill
rename notice_4months notice
rename disconnect_4months disconnect
rename electronic_device4 electronic_device
rename energybill_change4 energybill_change
rename stimulus_4mos stimulus
rename energy_assistance_4mos energy_assistance
rename gov_agency_4mos gov_agency
rename energy_provider_4mos energy_provider
rename friend_family_4mos friend_family
rename faith_org_4mos faith_org
rename nonprofit_4mos nonprofit
rename payday_lender_4mos payday_lender
rename bankloan_4mos bankloan
rename gov_assistance_4months gov_assistance
rename forego_expenses_4mos forego_expenses
rename wap_4mos wap
rename liheap_4mos liheap
rename snap_4mos snap
rename tanf_4mos tanf
rename ssi_4mos ssi
rename medicaid_4mos medicaid
rename vet_benefits_4mos vet_benefits
rename unemp_insurance_4mos unemp_insurance
rename stove_4mos stove
rename spaceheater_4mos spaceheater
rename woodstove_4mos woodstove
rename fireplace_4mos fireplace
rename hotshower_4mos hotshower
rename burntrash_4mos burntrash
rename heavycoat_4mos heavycoat
rename boughtice_4mos boughtice
rename coldshowers_4mos coldshower
rename dryer_4mos dryer
rename centralac_4mos centralac
rename windowac_4mos windowac
rename fan_4mos fan
rename dehumidifier_4mos dehumidifier
rename lefthouse_4mos lefthouse
rename openedwindows_4mos openedwindows
rename covid_employment4 covid_employment
rename covid_rent4 covid_rent
rename covid_feedfamily4 covid_feedfamily
rename covid_medicalcare4 covid_medicalcare
rename covid_lostinsurance4 covid_lostinsurance
rename date_unemployed4 date_unemployed
rename employed4 employed
rename unemployed4 unemployed
rename employ4 employ
rename efficient_appliances4 efficient_appliances
rename efficient_insulation4 efficient_insulation
rename efficient_ac4 efficient_ac
rename efficient_smartmeter4 efficient_smartmeter
rename efficient_lights4 efficient_lights
rename efficient_hometemp4 efficient_hometemp
rename efficient_devices4 efficient_devices
rename efficient_hungwindow4 efficient_hungwindow
rename utilitypay_check4 utilitypay_check
rename utilitypay_credit4 utilitypay_credit
rename utilitypay_debit4 utilitypay_debite
rename utilitypay_withdrawal4 utilitypay_withdrawal
rename utilitypay_cash4 utilitypay_cash
rename utilitybill_pay4 utilitybill_pay
rename utilityhelp_friend4 utilityhelp_friend
rename utilityhelp_paydayloan4 utilityhelp_paydayloan
rename utilityhelp_credit4 utilityhelp_credit
rename utilityhelp_notice4 utilityhelp_notice
rename utility_debt4 utility_debt
rename debt_over10004 debt_over1000
rename behind_rent4 behind_rent
rename behind_credit4 behind_credit
rename behind_car4 behind_car
rename behind_medical4 behind_medical
rename behind_bankloan4 behind_bankloan
rename behind_personalloan4 behind_personalloan
rename behind_studentloan4 behind_studentloan
rename evictnotice_4months evict_notice
rename evicted_4months evicted
rename legal_help4 legal_help
rename legal_access4 legal_access
rename legal_source4 legal_source
rename generalhealth_rate4 generalhealth_rate
rename prescription4 prescription
rename fill_prescription4 fill_prescription
rename mentalhealth_days4 mentalhealth_days
rename highbloodpressure4 highbloodpressure
rename heartdisease4 heartdisease
rename diabetes4 diabetes
rename cancer4 cancer
rename obesity4 obesity
rename asthma4 asthma
rename skipped_meals4 skipped_meals
rename skipped_meals_frequency4 skipped_meals_frequency
rename water_bill4 water_bill
rename water_shutoff4 water_shutoff
rename hh1_income4 hh1_income
rename hh2_income4 hh2_income
rename hh3_income4 hh3_income
rename hh4_income4 hh4_income
rename hh5_income4 hh5_income
rename hh6_income4 hh6_income
rename hh7_income4 hh7_income
rename hh8_income4 hh8_income
rename income4 income
rename sought_govagency4 sought_govagency
rename sought_bank4 sought_bank
rename sought_payday4 sought_payday
rename sought_utility4 sought_utility
rename sought_nonprofit4 sought_nonprofit
rename sought_faithbased4 sought_faithbased
rename sought_family_friends4 sought_family_friends
rename form_call4 form_call
rename form_letter4 form_letter 
rename form_doorknock4 form_doorknock 
rename form_email4 form_email 
rename form_text4 form_text
rename response_contactutility4 response_contactutility
rename response_paymentplan4 response_paymentplan
rename response_legalservices4 response_legalservices
rename response_assistance4 response_assistance
rename response_internet4 response_internet
rename response_homechanges4 response_homechanges
rename response_reduceenergy4 response_reduceenergy
rename response_moved4 response_moved
rename reconnection_cost4 reconnection_cost
rename response_moved_temp4 response_moved_temp
rename response_moved_perm4 response_moved_perm
rename response_livedwithout4 response_livedwithout
rename response_otherhelp4 response_otherhelp
rename response_paidoff4 response_paidoff
rename response_usedothers4 response_usedothers
rename response_carorbattery4 response_carorbattery
rename no_ac4 no_ac
rename no_ac_reason4 no_ac_reason




save wave4_energy_insecurity.dta, replace



***Append datasets***
clear all

use wave1_energy_insecurity.dta, clear
append using wave2_energy_insecurity.dta
append using wave3_energy_insecurity.dta
append using wave4_energy_insecurity.dta


recode zip *=. if zip==544

order wave, after(caseid_w1)

**generate variables for energy insecurity in the previous 12 months (May 2019-May 2020)
rename hhbill_year hhbill_previousyear
rename notice_year notice_previousyear
label define notice_yrlabel 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11"
label values notice_previousyear notice_yrlabel
rename disconnect_year disconnect_previousyear
label define disconnect_yrlabel 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11"
label values disconnect_previousyear disconnect_yrlabel
rename hhbill_3months1 hhbill_previous3months
rename notice_3months1 notice_previous3months
label define notice_3mlabel 1 "1" 2 "2" 3 "3"
label values notice_previous3months notice_3mlabel
rename disconnect_3months1 disconnect_previous3months
label define disconnect_3mlabel 1 "1" 2 "2" 3 "3"
label values disconnect_previous3months disconnect_3mlabel




save waves_energy_insecurity.dta, replace
use waves_energy_insecurity.dta

**incroporating dwelling type responses for respondents who moved
replace dwelling_type=. if dwelling_type2 !=.
replace dwelling_type=. if dwelling_type3 !=.
replace dwelling_type=. if dwelling_type4 !=.

gen dwelling_typeX=. if dwelling_type==.
replace dwelling_typeX=1 if dwelling_type==1 | dwelling_type2==1 | dwelling_type3 ==1 | dwelling_type4==1
replace dwelling_typeX=2 if dwelling_type==2 | dwelling_type2==2 | dwelling_type3 ==2 | dwelling_type4==2
replace dwelling_typeX=3 if dwelling_type==3 | dwelling_type2==3 | dwelling_type3 ==3 | dwelling_type4==3
replace dwelling_typeX=4 if dwelling_type==4 | dwelling_type2==4 | dwelling_type3 ==4 | dwelling_type4==4
replace dwelling_typeX=5 if dwelling_type==5 | dwelling_type2==5 | dwelling_type3 ==5 | dwelling_type4==5
label define dwellingX_label 1 "Trailer or mobile home" 2 "Apartment/duplex/condominum" 3 "Detached, single family home" 4 "Attached single family home" 5 "Other"
label values dwelling_typeX dwellingX_label
drop dwelling_type dwelling_type2 dwelling_type3 dwelling_type4
rename dwelling_typeX dwelling_type


save waves_energy_insecurity.dta, replace